package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.dto.DishPageQueryDTO;
import com.sky.pojo.Dish;
import com.sky.result.Result;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 查询菜品关联分类
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    /**
     * 插入菜品
     * @param dish
     */
    void insert(Dish dish);

    /**
     * 菜品分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 查询菜品状态
     * @param id
     * @return
     */
    @Select("select status from dish where id = #{id}")
    Dish getById(Integer id);


    /**
     * 删除菜品
     * @param ids
     */
    void deleteByIds(@Param("ids") List<Integer> ids);

    /**
     * 根据id查询菜品
     * @param dishId
     * @return
     */
    @Select("select * from dish where id=#{dishId}")
    Dish getDishById(Long dishId);

    void update(Dish dish);


    List<Dish> list(Dish dish);

    List<Dish> getSetmealById(Long id);

    @Select("select * from dish where category_id=#{categoryId} and status = 1")
    List<Dish> getDishByCategoryId(Integer categoryId);


    Integer getStatus(Map map);
}
